<?php
/**
 * This file contains the class PersonModel which provides
 * most of the code requirements for the a person
 *
 * @copyright  2009 A Memory Tree
 * @license    A Memory Tree License
 */
/**
 * This class provides the code for the person notices page
 *
 * @copyright  2009 A Memory Tree
 * @license    A Memory Tree License
 */
class PersonModel
{
    /**
     * Access to the database methods
     *
     * @var PersonDB
     */
    private $_db;
    /**
     * Access to the View methods
     *
     * @var PersonView
     */
    private $_view;
    /**
     * Create a new instance of this class
     *
     * @return void
     * @param PersonDB $db
     * @param PersonView $view
     */
    public function __construct($db, $view)
    {
        $this->_db = $db;
        $this->_view = $view;
    }
    function showaka($aka) {
        $view = $this->_view;
        if(strlen($aka) > 0) {
            return $view->aka($aka);
        }
    }
    function shownee($nee) {
        $view = $this->_view;
        if(strlen($nee) > 0) {
            return $view->nee($nee);
        }
    }
    function showformerly($former) {
        $view = $this->_view;
        if(strlen($former) > 0) {
            return $view->former($former);
        }
    }
    function showneeandformer($nee, $former) {
        $view = $this->_view;
        $neeAndFormer = '';
        $nee = $this->shownee($nee);
        $former = $this->showformerly($former);
        if(strlen($nee) > 0 || strlen($former) > 0) {
            $neeAndFormer = $view->neeAndFormer($nee, $former);
        }
        return $neeAndFormer;
    }
    function showdeathdate($deathdate) {
        $view = $this->_view;
        if(strlen($deathdate) > 0) {
            return $view->deathDate($deathdate);
        }
    }
    function formatdatetime($date) {
        if($date == "0000-00-00 00:00:00") {
            return "";
        }   else {
            return date('d F Y', strtotime(str_replace("&", "&amp;", $date)));
        }
    }
    function formatshortdatetime($date) {
        if($date == "0000-00-00 00:00:00") {
            return "";
        }   else {
            return date('d M Y', strtotime(str_replace("&", "&amp;", $date)));
        }
    }
    function showage($age, $extra) {
        $view = $this->_view;
        $text = '';
        if($age > 0) {
            $text = $view->age($age, $extra);
        }
        return $text;
    }
}
?>